<template>
  <!-- 主页面 -->
  <div class="home">
    <!-- 顶部栏 -->
    <el-header height="60px">
      <div class="header-left">
        <img src="../assets/images/home-logo.png" alt="" />
        <h2 class="title">冒险岛Online后台管理系统</h2>
      </div>
      <aplayer
        ref="aplayer"
        :music="{
          title: musicTitle,
          artist: 'MapleStory',
          src: 'http://127.0.0.1:1314/map_bgm/FirstStepMaster.mp3',
          pic: ''
        }"
        :float="false"
      />
      <div class="header-right">
        <div style="display: flex;align-item: center;">
          <el-button type="info" @click="loginOut">退出登录</el-button>
        </div>
      </div>
    </el-header>
    <el-container>
      <!-- 左侧菜单栏 -->
      <el-aside width="200px">
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :router="true"
        >
          <el-menu-item index="/dashboard">
            <i class="iconfont icon-shouye"></i>
            <span>首页</span>
          </el-menu-item>
          <!-- <el-submenu index="1">
            <template slot="title">
              <i class="iconfont icon-yonghu1"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item index="/adminUsers">
              <i class="iconfont icon-guanli"></i>
              <span>后台用户列表</span>
            </el-menu-item>
          </el-submenu> -->
          <!-- <el-submenu index="2">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>权限管理</span>
            </template>
            <el-menu-item index="/adminRoles">
              <i class="iconfont icon-guanli"></i>
              <span>后台角色列表</span>
            </el-menu-item>
            <el-menu-item index="/adminRights">
              <i class="iconfont icon-guanli"></i>
              <span>后台权限列表</span>
            </el-menu-item>
          </el-submenu> -->
          <!-- <el-submenu index="3">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>GM管理</span>
            </template>
            <el-menu-item index="/gmAccount">
              <i class="iconfont icon-guanli"></i>
              <span>GM账号列表</span>
            </el-menu-item>
            <el-menu-item index="/gmRoles">
              <i class="iconfont icon-guanli"></i>
              <span>GM角色列表</span>
            </el-menu-item>
          </el-submenu> -->
          <el-submenu index="4">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>玩家管理</span>
            </template>
            <el-menu-item index="/playerAccount">
              <i class="iconfont icon-guanli"></i>
              <span>玩家账号列表</span>
            </el-menu-item>
            <el-menu-item index="/playerRoles">
              <i class="iconfont icon-guanli"></i>
              <span>玩家角色列表</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="5">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>职业管理</span>
            </template>
            <el-menu-item index="/jobs">
              <i class="iconfont icon-guanli"></i>
              <span>职业列表</span>
            </el-menu-item>
            <!-- <el-menu-item index="/skills">
              <i class="iconfont icon-guanli"></i>
              <span>技能列表</span>
            </el-menu-item> -->
          </el-submenu>
          <el-submenu index="6">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>世界管理</span>
            </template>
            <el-menu-item index="/map">
              <i class="iconfont icon-guanli"></i>
              <span>地图管理</span>
            </el-menu-item>
            <el-menu-item index="/mob">
              <i class="iconfont icon-guanli"></i>
              <span>怪物管理</span>
            </el-menu-item>
            <el-menu-item index="/eqp">
              <i class="iconfont icon-guanli"></i>
              <span>装备管理</span>
            </el-menu-item>
            <el-menu-item index="/items">
              <i class="iconfont icon-guanli"></i>
              <span>物品管理</span>
            </el-menu-item>
            <el-menu-item index="/pets">
              <i class="iconfont icon-guanli"></i>
              <span>宠物管理</span>
            </el-menu-item>
            <!-- <el-menu-item index="/dungeon">
              <i class="iconfont icon-guanli"></i>
              <span>副本管理</span>
            </el-menu-item> -->
            <el-menu-item index="/npc">
              <i class="iconfont icon-guanli"></i>
              <span>NPC管理</span>
            </el-menu-item>
            <el-menu-item index="/burst">
              <i class="iconfont icon-guanli"></i>
              <span>爆率管理</span>
            </el-menu-item>
            <el-menu-item index="/shop">
              <i class="iconfont icon-guanli"></i>
              <span>商店管理</span>
            </el-menu-item>
            <!-- <el-menu-item index="/quest">
              <i class="iconfont icon-guanli"></i>
              <span>任务列表</span>
            </el-menu-item> -->
          </el-submenu>
          <el-submenu index="7">
            <template slot="title">
              <i class="iconfont icon-quanxian"></i>
              <span>商城管理</span>
            </template>
            <el-menu-item index="/cash">
              <i class="iconfont icon-guanli"></i>
              <span>现金物品列表</span>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 主题内容区域 -->
      <el-main>
        <router-view @play-music="playMusic($event)"></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import Aplayer from 'vue-aplayer';
export default {
  data () {
    return {
      musicTitle: 'NO-BGM',
      bgmSrc: 'http://127.0.0.1:1314/map_bgm/'
    };
  },
  methods: {
    loginOut () {
      // 退出登录功能
      // 调用确认框
      this.$confirm('你确定要退出系统吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // 清楚本地token
          window.localStorage.removeItem('token');
          // 提示成功信息
          this.$message.success('退出登陆成功');
          // 跳转到登录页
          this.$router.push('/login');
        })
        .catch(() => {});
    },
    playMusic (obj) {
      console.log(document.querySelector('.aplayer-pic'));
      this.musicTitle = obj.name;
      this.bgmSrc = obj.url + '.mp3';
      document.querySelector('.aplayer-pic').click();
      console.log(this.$refs.aplayer);
    }
    // durationchange () {
    //   this.$refs.aplayer.toggle();
    // }
  },
  mounted () {
    console.log(this.$refs.aplayer);
  },
  components: {
    aplayer: Aplayer
  }
};
</script>

<style lang="less" scoped>
.home /deep/ .el-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #373d41;
}
.home /deep/ .el-aside {
  overflow-x: hidden;
  // height: 100%;
  background-color: #333744;
}
.home {
  display: flex;
  flex-direction: column;
  height: 100%;
  /deep/ .el-container {
    flex: 1;
    // height: 100%;
    .el-menu {
      width: 200px;
      background-color: #333744 !important;
      .iconfont {
        margin-right: 10px;
      }
      .el-menu-item {
        width: 200px;
        font-size: 12px !important;
        background-color: #333744 !important;
        &:hover {
          background-color: #292c36 !important;
        }
        &.is-active {
          color: #409eff !important;
        }
      }
      .el-submenu__title {
        width: 200px;
        font-size: 12px !important;
        background-color: #333744 !important;
        &:hover {
          background-color: #292c36 !important;
        }
      }
    }
  }
}
.header-left {
  display: flex;
  align-items: center;
  img {
    width: 60px;
    height: 60px;
  }
  .title {
    color: #fff;
    font-weight: 400;
  }
}
.header-right {
  display: flex;
}
</style>
<style lang="less">
.search-container {
  display: flex;
  align-items: center;
  .el-input {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }
  .el-button {
    height: 40px;
    color: #909399 !important;
    border-color: #d3d4d6 !important;
    background-color: #f5f7fa !important;
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    &:hover {
      color: #909399 !important;
      background-color: #f5f7fa !important;
      border-color: #d3d4d6 !important;
    }
  }
}
.search-container {
  .el-input__inner {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }
}
.pagination {
  margin-top: 15px;
  padding: 0 10px;
}
.el-table {
  margin-top: 15px;
  th,
  td {
    font-size: 12px;
  }
}
.el-table__header {
  .gutter {
    display: block !important;
  }
}
.box-card {
  margin-top: 15px;
}
.el-breadcrumb {
  font-size: 12px;
}
.el-main {
  background-color: #eaedf1;
}

.aplayer {
  background-color: transparent !important;
  justify-self: flex-end !important;
}
.aplayer-body {
  background-color: transparent;
}
.aplayer-info,
.aplayer-pic {
  background-color: #eaedf1;
  height: 50px !important;
}
.aplayer-info {
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
}
.aplayer-pic {
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
}
</style>
